#include <gst/player/gstplayer-video-renderer.h>
+#include <math.h>
+
struct _GtkGstPaintable
{
GObject parent_instance;
GdkPaintable *image;
+ double pixel_aspect_ratio;
};
struct _GtkGstPaintableClass
GtkGstPaintable *self = GTK_GST_PAINTABLE (paintable);
if (self->image)
- return gdk_paintable_get_intrinsic_width (self->image);
+ return round (self->pixel_aspect_ratio *
+ gdk_paintable_get_intrinsic_width (self->image));
return 0;
}
GtkGstPaintable *self = GTK_GST_PAINTABLE (paintable);
if (self->image)
- return gdk_paintable_get_intrinsic_aspect_ratio (self->image);
+ return self->pixel_aspect_ratio *
+ gdk_paintable_get_intrinsic_aspect_ratio (self->image);
return 0.0;
};
static void
gtk_gst_paintable_set_paintable (GtkGstPaintable *self,
- GdkPaintable *paintable)
+ GdkPaintable *paintable,
+ double pixel_aspect_ratio)
{
gboolean size_changed;
return;
if (self->image == NULL ||
- gdk_paintable_get_intrinsic_width (self->image) != gdk_paintable_get_intrinsic_width (paintable) ||
+ self->pixel_aspect_ratio * gdk_paintable_get_intrinsic_width (self->image) !=
+ pixel_aspect_ratio * gdk_paintable_get_intrinsic_width (paintable) ||
gdk_paintable_get_intrinsic_height (self->image) != gdk_paintable_get_intrinsic_height (paintable) ||
gdk_paintable_get_intrinsic_aspect_ratio (self->image) != gdk_paintable_get_intrinsic_aspect_ratio (paintable))
size_changed = TRUE;
size_changed = FALSE;
g_set_object (&self->image, paintable);
+ self->pixel_aspect_ratio = pixel_aspect_ratio;
if (size_changed)
gdk_paintable_invalidate_size (GDK_PAINTABLE (self));
struct _SetTextureInvocation {
GtkGstPaintable *paintable;
GdkTexture *texture;
+ double pixel_aspect_ratio;
};
static void
SetTextureInvocation *invoke = data;
gtk_gst_paintable_set_paintable (invoke->paintable,
- GDK_PAINTABLE (invoke->texture));
+ GDK_PAINTABLE (invoke->texture),
+ invoke->pixel_aspect_ratio);
return G_SOURCE_REMOVE;
}
void
gtk_gst_paintable_queue_set_texture (GtkGstPaintable *self,
- GdkTexture *texture)
+ GdkTexture *texture,
+ double pixel_aspect_ratio)
{
SetTextureInvocation *invoke;
invoke = g_slice_new0 (SetTextureInvocation);
invoke->paintable = g_object_ref (self);
invoke->texture = g_object_ref (texture);
+ invoke->pixel_aspect_ratio = pixel_aspect_ratio;
g_main_context_invoke_full (NULL,
G_PRIORITY_DEFAULT,
static GdkTexture *
gtk_gst_sink_texture_from_buffer (GtkGstSink *self,
- GstBuffer *buffer)
+ GstBuffer *buffer,
+ double *pixel_aspect_ratio)
{
GstVideoFrame frame;
GdkTexture *texture;
frame.info.stride[0]);
g_bytes_unref (bytes);
+ *pixel_aspect_ratio = ((double) frame.info.par_n) / ((double) frame.info.par_d);
+
return texture;
}
{
GtkGstSink *self;
GdkTexture *texture;
+ double pixel_aspect_ratio;
GST_TRACE ("rendering buffer:%p", buf);
GST_OBJECT_LOCK (self);
- texture = gtk_gst_sink_texture_from_buffer (self, buf);
+ texture = gtk_gst_sink_texture_from_buffer (self, buf, &pixel_aspect_ratio);
if (texture)
{
- gtk_gst_paintable_queue_set_texture (self->paintable, texture);
+ gtk_gst_paintable_queue_set_texture (self->paintable, texture, pixel_aspect_ratio);
g_object_unref (texture);
}